package com.CmJava.tomcat.Server.service.container;

import com.CmJava.tomcat.Server.Component;
import com.CmJava.tomcat.Server.life.Lifecycle;
import com.CmJava.tomcat.Server.life.LifecycleState;
import com.CmJava.tomcat.Server.service.connector.Connector;

public class Host implements Lifecycle, Component {
    private String host="localhost";
    private LifecycleState lifecycleState=LifecycleState.NEW;
    private Component child;


    public Host(Component child) {
        this.child = child;
    }

    public Component getChild() {
        return child;
    }

    public void setChild(Component child) {
        this.child = child;
    }

    @Override
    public void init() {
        Context context = new Context(null);
        context.init();
        child=context;
        lifecycleState=LifecycleState.INITIALIZED;
    }

    @Override
    public void start() {
        if (!Connector.request.getHost().equals(host)) {
            return;
        }
        Context context = (Context) child;
        context.start();
    }

    @Override
    public void stop() {

    }

    @Override
    public void destroy() {

    }

    @Override
    public LifecycleState getState() {
        return null;
    }
}
